package files;

import general.Pair;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

public class Files {


	public void createFiles(int count, String name) {

		for (int i = 0; i < count; i++) {
			String text;

			File f = new File(name + Integer.toString(i));
			if(!f.exists()) f.mkdirs();
			try {
				f.createNewFile();
				writeToFile(f,GenerateWord.generateRandomWord(5, 4, 15));
				
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

private void writeToFile(File file, String text) throws IOException{
	
	BufferedWriter output = new BufferedWriter(new FileWriter(file));
	text = GenerateWord.generateRandomWord(4, 3, 15);
	output.write(text);
	output.close();
}

public String readFromFile(File file) throws IOException{
	
	String everything; 
	try(BufferedReader bufferReader = new BufferedReader(new FileReader(file))) {
	        StringBuilder stringBuilder = new StringBuilder();
	        String line = bufferReader.readLine();

	        while (line != null) {
	            stringBuilder.append(line);
	            stringBuilder.append(System.lineSeparator());
	            line = bufferReader.readLine();
	        }
	        everything = stringBuilder.toString();
	    }
	 
	 return everything;
	 
	
}


public static void deleteFiles(String path)
{
	/*
	 * 
	 */
}
}
